/*
 * Copyright (c) laokz <laokz@foxmail.com>
 * VMWIFI is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
#ifndef __VW_H__
#define __VW_H__

#include <errno.h>

#define OUT_IF_ERR(code)   do {         \
    if ((code) < 0) {                   \
        fprintf(stderr, "%s:%d %s\n", __func__, __LINE__, strerror(errno)); \
        ret = -1;                       \
        goto OUT;                       \
    }                                   \
} while(0)

#define NL_OUT_IF_ERR(code)   do {      \
    if ((code) < 0) {                   \
        fprintf(stderr, "%s:%d %s\n", __func__, __LINE__, nl_geterror(code)); \
        ret = -1;                       \
        goto OUT;                       \
    }                                   \
} while(0)


#define OUT_IF_ERR_PTR(ptr)     do {    \
    if ((ptr) == NULL) {                \
        fprintf(stderr, "%s:%d failed\n", __func__, __LINE__); \
        ret = -1;                       \
        goto OUT;                       \
    }                                   \
} while(0)

#define OUT_IF__1(code)     do {    \
    if ((code) < 0) {               \
        ret = -1;                   \
        goto OUT;                   \
    }                               \
} while(0)

#define LOG(...)    fprintf(stderr, __VA_ARGS__)

int InitVwEther(const char *iface);
void DeinitVwEther(void);

#endif
